import pygame as pg
import sys

sbd = 255
pg.init()
screen = pg.display.set_mode((800, 600))
pg.display.set_caption('hello!')
picture = pg.image.load('NS.png')
picture_up = pg.transform.rotate(picture, 90)
picture_right = picture
picture_left = pg.transform.rotate(picture, 180)
picture_down = pg.transform.rotate(picture, 270)
# picture.fill((255, 0, 0))
position = picture.get_rect()
position = position.move([400, 300])
font = pg.font.Font(None, 20)
height = font.get_linesize()
list1 = [3, 2]
pos = 0

while True:
    for event in pg.event.get():
        font1 = font.render(str(event), True, (0, 255, 0))
        font1 = pg.transform.flip(font1, True, False)
        if event.type == pg.QUIT:
            sys.exit()
        # screen.blit(font1, pos)
        # pos += height
        if event.type == pg.KEYDOWN:
            print('hello')
        print(position.top, position.right)
        # position = position.move([-10, 0])
    position = position.move(list1)
    
    if position.top < 0:
        position.top = 0
        picture = picture_up
        list1 = [-3, 0]
    if position.bottom > 600:
        position.bottom = 600
        picture = picture_down
        list1 = [3, 0]
    if position.left < 0:
        position.left = 0
        picture = picture_left
        list1 = [0, 3]
    if position.right > 800:
        position.right = 800
        picture = picture_right
        list1 = [0, -3]
    
    screen.blit(picture, position)
    if pos > 800:
        pos = 0
        screen.fill((0, 0, 0))
    pg.display.update()
    pg.time.Clock().tick(400)
